<?
//namespace nz\co\innovanet\fta;

	/**
		FTAObject is a base object that all FTA Classes will extend from, at this point in time it does
		squat.
	*/
	class FTAObject {
	
		var $data;
		 
		function __construct(){
			$this->data = array();
		}
		
		function render(){}
	
		//void __set ( string $name , mixed $value )
		function __set($name, $value){
			
			$methodName = 'set' . ucfirst($name);
			if(method_exists($this,$methodName)){
				$this->{ $methodName }($value);
				return;
			}
			$this->data[$name] = $value;
		}

		//mixed __get ( string $name )
		function __get($name){
			
			
			//method hackage.. like cmskvc..
			$methodName = 'get' . ucfirst($name);

			if(method_exists($this,$methodName)){
				return $this->{ $methodName }();
			}
			
			//public objects??
			
			//otherwise.. internal array
			if (array_key_exists($name, $this->data)) {
				return $this->data[$name];
			}
			
			$trace = debug_backtrace();
			trigger_error(
		           'Undefined property ' . "<b>'" . $name ."'</b> via __get() ". 
		           ' in ' . $trace[0]['file'] .
		           ' on line ' . $trace[0]['line'], //."\n called by ".$trace[1]['file'] . " on line " .  $trace[1]['line'] ,
		           E_USER_NOTICE);
		           
			return null;
		}
				
		//bool __isset ( string $name )
		function __isset($name){
			$getMethodName = 'get' . ucfirst($name);
			if (method_exists($this,$getMethodName)) {
				return true;
			}
			
			return array_key_exists($name,$this->data) ;//&& isset($this->data[$name]// this returns true if the key exists but it is null..
		}
				
		//void __unset ( string $name )
		function __unset($name) {
			$getMethodName = 'get' . ucfirst($name);
			if (method_exists($this,$getMethodName)) {
				$trace = debug_backtrace();
				trigger_error(
		           "can't unset <b>'" . $name ."'</b> via __unset() ".
		           ' in ' . $trace[0]['file'] .
		           ' on line ' . $trace[0]['line'],
		           E_USER_NOTICE);			
			}
			unset($this->data[$name]);
		}
					
	}